package com.zhengtoudai.ui.presenter;

import android.content.Context;

import com.zhengtoudai.base.LowBasePresenter;
import com.zhengtoudai.http.HttpApi;
import com.zhengtoudai.http.callback.ApiCallback;
import com.zhengtoudai.http.callback.SubscriberCallBack;
import com.zhengtoudai.ui.bean.TransferModel;
import com.zhengtoudai.ui.view.TransferView;

import java.util.Map;

/**
 * 作者：黑哥 on 2016/8/29 13:26
 */
public class TransferPresenter extends LowBasePresenter<TransferView> {

    public TransferPresenter(TransferView view) {
        attachView(view);
    }

    public void loadData(Context context, Map<String,String> params) {
        mvpView.showLoading();
        addSubscription(HttpApi.getInstance().getTransferList(params), new SubscriberCallBack<>(context,new ApiCallback<TransferModel>() {
            @Override
            public void onSuccess(TransferModel model) {
                mvpView.getDataSuccess(model);
            }

            @Override
            public void onFailure(int code, String msg) {

                mvpView.getDataFail(msg);
            }

            @Override
            public void onCompleted() {
                mvpView.hideLoading();
            }

            @Override
            public void onError(Throwable e) {

            }

        }));
    }
}
